#bin/bash
FILE_NAME=$1
echo "$FILE_NAME"

delete_files() {
    for file in "$1"/*; do
        if [[ -d "$file" ]]; then
            delete_files "$file"  # 递归调用，处理子文件夹
        elif [[ -f "$file" ]]; then
            filename=$(basename "$file")  # 获取文件名部分
            if [[ $filename == $FILE_NAME* ]]; then
                rm "$file"
                echo "Deleted file: $file"
            fi
        fi
    done
}

# 指定要删除文件的文件夹路径
folder_path="./internal"
if [[ -n "$FILE_NAME" ]]; then
    delete_files "$folder_path"
fi



# # 指定要删除文件的文件夹路径
# folder_path="./internal"
# delete_files "$folder_path"


delete_files() {
    for file in "$1"/*; do
        if [[ -d "$file" ]]; then
            delete_files "$file"  # 递归调用，处理子文件夹
        elif [[ -f "$file" && "$file" == *_test.go ]]; then
            rm "$file"
            echo "Deleted file: $file"
        fi
    done
}

# 指定要删除文件的文件夹路径
folder_path="./internal"
delete_files "$folder_path"
